package com.gl.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.pojo.RecommendGroup;
import com.haixiaoke.saas.repository.service.IRecommendGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 推荐房源组Controller
 * 
 * @author 志平
 * @date 2023-04-18
 */
@RestController
@RequestMapping("/recommend/recommendGroup")
public class RecommendGroupController extends BaseController {
    @Autowired
    private IRecommendGroupService recommendGroupService;

    /**
     * 查询推荐房源组列表
     */
    @GetMapping("/list")
    public AjaxResult list(RecommendGroup recommendGroup) {
        return success(recommendGroupService.selectRecommendGroupList(recommendGroup));
    }


    /**
     * 获取推荐房源组详细信息
     */
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId) {
        return success(recommendGroupService.selectRecommendGroupByGroupId(groupId));
    }

    /**
     * 新增推荐房源组
     */
    @PostMapping
    public AjaxResult add(@RequestBody RecommendGroup recommendGroup) {
        return toAjax(recommendGroupService.insertRecommendGroup(recommendGroup));
    }

    /**
     * 修改推荐房源组
     */
    @PutMapping
    public AjaxResult edit(@RequestBody RecommendGroup recommendGroup) {
        return toAjax(recommendGroupService.updateRecommendGroup(recommendGroup));
    }

    /**
     * 删除推荐房源组
     */
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds) {
        return toAjax(recommendGroupService.deleteRecommendGroupByGroupIds(groupIds));
    }
}
